﻿/// <reference path="RequestHandler.js" />
/// <reference path="../HttpRequest.js" />
///--------------------------------------------------------------------
/// <file name="CreateBlogPostHandler.js">
///   Adds functionality to the page where users create blog posts.
/// </file>
///--------------------------------------------------------------------

NAMFox.ns(function() { with (NAMFox) {

this.CreateBlogPostHandler = function() {
};

CreateBlogPostHandler.prototype = new RequestHandler();
CreateBlogPostHandler.prototype.name = "CreateBlogPostHandler";

CreateBlogPostHandler.prototype.handleRequestCore = function(request, _$) {
    /// <summary>Handles a request.</summary>
    /// <param name="request" type="HttpRequest">
    ///   The HTTP request which encapsulates the
    ///   document and route data for this request.
    /// </param>

    var previewMessage = _$("#message_box");
    
    if (
        previewMessage.length === 1 &&
        previewMessage.html() === "You are currently previewing your blog post!"
    ) {
        return;
    }
    
    var textArea = _$("textarea[name=blog_post]");
    
    if (textArea.length === 1 && !textArea.val()) {
        textArea.val($.messages.getDefaultMessage().text);
    }
};

}});